using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TaskUI : MonoBehaviour
{
   private List<Item> items=new List<Item>();

    private UIAnimatorControl<Item> uiAnimatorControl;

    private void Awake()
    {
        uiAnimatorControl = GetComponent<UIAnimatorControl<Item>>();
    }
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Debug.Log("测试增加物品");
            TestData(0, "张三", "道具", 1);
            TestData(1, "李四", "道具", 12);
            TestData(2, "王五", "道具", 1);
            TestData(3, "赵六", "武器", 10);
        }
    }

    private void TestData(int id, string name, string kinds, int conut)
    {
        ItemData data = new ItemData();
        data.Id = id;
        data.Name=name;
        data.Kinds=kinds;
        Item item = new Item(data);
        item.ItemInfo.count=conut;
        AddItem(item);
    }

    private void AddItem(Item item)
    {
        if(!items.Contains(item))
        {
            items.Add(item);
        }
        uiAnimatorControl.UpdateData(items);
    }
}
